package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormDeviceInDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormDeviceInDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormDeviceInDetailConverter {

    public static FlowFormDeviceInDetailDto do2Dto(FlowFormDeviceInDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormDeviceInDetailDto dto = FlowFormDeviceInDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormDeviceInDetailDto> do2Dto(List<FlowFormDeviceInDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormDeviceInDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormDeviceInDetail dto2Do(FlowFormDeviceInDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormDeviceInDetail domain = FlowFormDeviceInDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormDeviceInDetail> dto2Do(List<FlowFormDeviceInDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormDeviceInDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormDeviceInDetailMapper {

        FlowFormDeviceInDetailMapper INSTANCE = Mappers.getMapper(FlowFormDeviceInDetailMapper.class);

        FlowFormDeviceInDetailDto do2Dto(FlowFormDeviceInDetail domain);

        List<FlowFormDeviceInDetailDto> do2Dto(List<FlowFormDeviceInDetail> domain);

        FlowFormDeviceInDetail dto2Do(FlowFormDeviceInDetailDto dto);

        List<FlowFormDeviceInDetail> dto2Do(List<FlowFormDeviceInDetailDto> dto);
    }
}
